package com.evil.application.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evil.application.pojo.dto.ApplicationReqDTO;
import com.evil.application.pojo.entity.PackageApplication;
import com.evil.common.application.dto.SourcesDTO;
import com.evil.common.application.dto.pkg.PackageApplicationSourceDTO;
import com.evil.common.application.dto.pkg.PackageApplicationSourcesDTO;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

/**
 * 应用包应用表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface PackageApplicationMapper extends BaseMapper<PackageApplication> {

    Optional<PackageApplication> findPackage(@Param("sourceType") Integer sourceType,
                                             @Param("sourceId") Long sourceId,
                                             @Param("packageId") Long packageId);

    List<PackageApplication> findByIds(@Param("ids") Collection<Long> ids, @Param("filterDeleted") boolean filterDeleted);

    List<PackageApplication> findBySource(PackageApplicationSourceDTO sourceDTO);

    List<PackageApplication> findBySources(SourcesDTO sources);

    List<PackageApplication> findByPackageSources(PackageApplicationSourcesDTO sources);

    List<PackageApplication> findByPackageId(Long packageId);

    List<PackageApplication> findByApplicationReqDTO(ApplicationReqDTO applicationReqDTO);

    int findMaxSortByApplicationPackageId(Long packageId);
}